package 力扣日常刷题.木22二月.第01天206;

/**
 * @author 帅小伙
 * @date 2022/2/6
 * @description
 */
public class Demo06搜索二维矩m加n {
    public boolean searchMatrix(int[][] matrix, int target) {
        int x = matrix.length, y = matrix[0].length;

        int curX = 0, curY = y - 1;
        while(curX < x && curY >= 0){
            if(matrix[curX][curY] == target)return true;
            else if(matrix[curX][curY] < target)curX ++;
            else curY --;
        }

        return false;
    }

}
